﻿using Domain.Entity;
using DtoFw.Query;
using Repository.Base;
using System;
using System.Collections.Generic;
using System.Text;
using Util;

namespace Repository
{
    public class RoomAreaRepository : BaseRepository<RoomAreaEntity>
    {
        private readonly SnowFlakeGenerator worker;
        public RoomAreaRepository(SnowFlakeGenerator snowFlakeGenerator) : base(snowFlakeGenerator)
        {
            this.worker = snowFlakeGenerator;

        }

        /// <summary>
        /// 根据物品编号查询
        /// </summary>
        /// <param name="eveidenceNo"></param>
        public EvidenceToAreaDto GetEvidenceByEviNo(string eveidenceNo, long organId)
        {

            string sql = @$"select a0.caseNo,a1.name caseName,a4.AreaId,a1.`Name` evidenceName,a1.`No` evidenceNo, a1.Status,a2.Location  from  case_physical_evidence  A1
                             left join cases a0 on  a0.id=a1.CaseId
                             left join case_physical_evidence_transfere A2 ON A1.ID=a2.EvidenceId  and a2.HistoryStatus=0   
                             left join room_box a3 on a3.id=a2.LocationId
                             left join room_cabinet a4 on a3.CabinetId= a4.id
                             where a1.No='{eveidenceNo}' and a1.organId={organId}  ";

            return base.GetDb().Ado.SqlQuerySingle<EvidenceToAreaDto>(sql);

        }
    }
}
